/*
 * @Author: zhaiyujia
 * @Date: 2022-11-16 00:43:31
 * @LastEditors: zhaiyujia
 * @LastEditTime: 2022-11-24 03:18:44
 * @Description: ws2812&max9814 test.
 */

#include "Arduino.h"

#define MIC_PIN D11
#define LED_PIN D55
#define LED_REG P55
#define LED_NUM 16
#include "ws2812.h"
#include "color.h"
uint8_t leds[LED_NUM * 3];

void setup()
{
    pinMode(MIC_PIN, INPUT);  // mic out pin
    pinMode(LED_PIN, OUTPUT); // led data pin
    Serial_begin(115200);     //
    delay(1100);              // Wait for STC-ISP to open the serial port
    Serial_println("Hello Arduino-STC.");
    rainbowColor(&leds, LED_NUM, 1);
}
void loop()
{
    uint16_t value = analogRead(D11);
    value = map(value, 0, 555, 0, 25);
    // Serial_printf("%u\r\n", (uint16_t)value);
    led_show(&leds, value);
    delay(10);
}